#!/bin/bash
# return an array value
testit (){
    local origarray
    local newarray
    local elements
    local i 
    origarray=($(echo  $@))
    newarray=($(echo $@))
    elements=$[ $# - 1 ]
    for ((i = 1; i<= elements; i++)){
        newarray[$i]=$[ origarray[$i] * 2 ]
    }
    echo ${newarray[*]}
    
}

myarray=(0 1 2 3 4 5)
echo "The original array is ${myarray[*]}"
arg1=$(echo "${myarray[*]}")
# 这里result接受每个元素之后成为一个独立的数组
result=($(testit $arg1))
echo "The result is ${result[*]}"

